// pages/campusTel/campusTel.js

import API from "../../data/api";
import Util from "../../utils/util";

const App = getApp();
const Config = App.Config;

Page({
  data: {
    listData: [],
    HOSTIMG: Config.HOSTIMG, // 图片
    windowWidth: App.globalData.systemInfo.windowWidth,
    windowHeight: App.globalData.systemInfo.windowHeight
  },
  onShow: function (options) {
    var that = this;
    that.getCampusTel();
  },
  // 获取校内电话
  getCampusTel: function () {
    var that = this;
    API.getCampusTel()
      .then((res) => {
        // console.log(res);
        if (res.data.error == Config.ERR.OK) {
          var newData = [];
          newData.push(...res.data.data);
          that.setData({ listData: newData });
        } else if (res.data.error == Config.ERR.ER) {
          Util.UI.loading(1000, res.data.data);
        }
      });
  },

  phoneCall: function (event) {
    // console.log(event.currentTarget.dataset.tel)
    wx.makePhoneCall({
      phoneNumber: event.currentTarget.dataset.tel //仅为示例，并非真实的电话号码
    })
  }

})